<template>
    <div v-loading="loading" element-loading-text="拼命加载中">

        <div class="content_top">
            <el-button type="primary" size="mini" @click="generateIng">生成</el-button>
            <span>&nbsp;&nbsp;&nbsp;上次生成时间：{{ data.createTime }}</span>
            <span>&nbsp;&nbsp;&nbsp;生成人：{{ data.createUserName }}</span>
        </div>

        <el-table :data="list" border stripe highlight-current-row style="width: 100%" size="mini">
            <el-table-column type="index" header-align="center" align="center" width="60px"/>
            <el-table-column prop="name" label="商品" header-align="center" align="center"/>
            <el-table-column prop="upLimit" label="采购上限（斤）" header-align="center" align="center"/>
            <el-table-column prop="downLimit" label="采购下限（斤）" header-align="center" align="center"/>
            <el-table-column prop="count" label="日销量（份）" header-align="center" align="center"/>
            <el-table-column prop="dayWeight" label="日销量（斤）" header-align="center" align="center"/>
            <el-table-column prop="weight" label="规格(份/斤)" header-align="center" align="center"/>
        </el-table>
    </div>
</template>

<script>

    import {getData, generate} from '@/api/goods/goods-purchase'

    export default {
        name: "purchase",
        data() {
            return {
                loading: false,
                data: {},
                list: []
            }
        },
        mounted() {
            this.loadData()
        },
        methods: {
            async loadData() {
                this.loading = true
                let res = await getData();
                this.loading = false
                this.data = res.data
                this.list = JSON.parse(res.data.content);
            },
            async generateIng() {
                this.loading = true
                let res = await generate();
                this.loading = false
                if (res.code !== '0') {
                    return this.$notify.error({title: '消息', message: res.message})
                }
                this.$notify.success({title: '消息', message: "生成成功"})
                this.loadData()
            }
        }
    }
</script>

<style scoped>

</style>